package com.ruoyi.web.controller.entity;

import com.alibaba.fastjson2.JSONObject;
import lombok.Data;

@Data
public class ConnectCallbackReqVO {

    private String UserId;
    private String RoomId;
    private int TotalNum;
    private String MediaType;
    private String CallType;
    private String CallId;
    private String Role;
    private String Event;
    private String CallResult;
    private Long EventTime;
    private Long StartCallTs;
    private Long AcceptTs;
    private Long EndTs;

    public String getCallStatus(){
        //呼叫状态 0 接通 1 挂断 2 未接通 3 取消
        switch (getCallResult()){
            case "not_answer": return "2";
            case "cancel": return "3";
            case "normal_end": return "0";
            case "reject": return "1";
            default:
                return "9";
        }
    }

    public ConnectCallbackReqVO(JSONObject json){
        setUserId(json.getString("UserId"));
        setRoomId(json.getString("RoomId"));
        setTotalNum(json.getInteger("TotalNum"));
        setMediaType(json.getString("MediaType"));
        setCallType(json.getString("CallType"));
        setCallId(json.getString("CallId"));
        setRole(json.getString("Role"));
        setEvent(json.getString("Event"));
        setCallResult(json.getString("CallResult"));
        setEventTime(json.getLong("EventTime"));
        setStartCallTs(json.getLong("StartCallTs"));
        setAcceptTs(json.getLong("AcceptTs"));
        setEndTs(json.getLong("EndTs"));
    }
}
